package com.ruleengine.worker.runner.chain;

import com.ruleengine.worker.model.Chain;
import com.ruleengine.worker.model.Status;

/**
 * ChainRunner Interface
 *
 * @author lianghanwei on 2024/3/3
 */
public interface ChainRunner<T> {
    /**
     * Start(enable) the chain runner
     * Initially, the chain runner is disabled, in which state the chain runner is not able to process item.
     * When chain runner is enabled, it starts processing item.
     */
    void start();

    /**
     * Stop(disable) the chain runner
     */
    void stop();

    /**
     * Close the chain runner
     * Only PENDING / ERROR status chain runner is allowed to close
     */
    void close();

    /**
     * Get the status of the chain
     */
    Status getStatus();

    /**
     * Process specified item
     */
    void process(T item);

    /**
     * Get the name of chain runner
     */
    String getChainName();

    /**
     * Get the uid of the chain runner
     */
    String getUid();

    /**
     * Get the chain of chain runner
     */
    Chain getChain();

    /**
     * Get the version of the chain runner
     */
    String getVersion();

    /**
     * Get current chain runner buffer size
     */
    int getBufferSize();
}
